package org.malred.jetpackcomposebasic

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview

class MainActivity01 : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            MessageCard(name = "My Android")
        }
    }

    @Composable // compose 控件
    fun MessageCard(name: String) {
        // compose: 文本控件
        Text(text = "Hello $name!")
    }

    @Preview // 预览
    @Composable
    // 预览函数不能带参数
    fun PreviewMessageCard() {
        MessageCard(name = "Android")
    }
}
